<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录验证</title>
</head>

<body style="display: flex;align-items: center;justify-content: center;">
    <svg width="52" height="52" class="loading">
        <path d="M24,2 a24,24 0 0,1 26,26" stroke-linecap="round" fill="none" stroke="black" stroke-width="4" />
    </svg>
</body>
<style>
    html, body{
        width: 100%;
        height: 100%;
        margin: 0;
    }
    .loading{
        animation: roling 800ms linear infinite;
        /* transform: rotate(30deg); */
    }
    @keyframes roling {
        0% {
            transform: rotate(0deg);
        }
        100% {
            transform: rotate(360deg);
        }
    }
</style>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="./jquery.cookie.min.js"></script>
<script>
    const url = new URL(window.location)
    const query = url.searchParams
    if (query.has('code')) {
        $.ajax({
            url: 'https://www.onecourse.top/authLogin',
            contentType: 'application/json',
            headers: {
                'access-control-request-headers': 'content-type',
                'access-control-request-method': 'POST'
            },
            data: JSON.stringify({
                type: 0,
                isApp: window.opener.platFormIsApp,
                code: query.get('code')
            }),
            method: 'post',
            success(data, status, _) {
                if (status == 'success') {
                    window.opener.LoginCallback({
                        code: 0,
                        access_token: data.access_token,
                        refresh_token: data.refresh_token
                    })
                } else {
                    window.opener.LoginCallback({
                        code: 1
                    })
                }
                window.close()
            },
            error() {
                window.opener.LoginCallback({
                    code: 1
                })
                // window.close()
            }
        })
    } else {
        window.opener.LoginCallback({
            code: 1
        })
        window.close()
    }
</script>

</html>